package com.mycompany.isd;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

public class App 
{
    public static void main( String[] args )
    {
        EntityManagerFactory uFactory = Persistence.createEntityManagerFactory("Users");
        EntityManager uManager = uFactory.createEntityManager();
        EntityManagerFactory sFactory = Persistence.createEntityManagerFactory("Systems");
        EntityManager sManager = sFactory.createEntityManager();
        EntityManagerFactory ssFactory = Persistence.createEntityManagerFactory("SubSys");
        EntityManager ssManager = ssFactory.createEntityManager();
        uManager.getTransaction().begin();
        sManager.getTransaction().begin();
        uManager.persist(new User(1, "ivan1"));
        uManager.persist(new User(2, "ivan2"));
        uManager.persist(new User(3, "ivan3"));
        sManager.persist(new Sys(1, "System1"));
        sManager.persist(new Sys(2, "System2"));
        sManager.persist(new Sys(3, "System3"));
        uManager.getTransaction().commit();
        sManager.getTransaction().commit();
    }
}
